<html>
<head>

    <script type="text/javascript" language="javascript">
        function validasi() {
            var name = document.getElementById("question").value;
            var pilA = document.getElementById("pilA").value;
            var pilB = document.getElementById("pilB").value;
            var pilC = document.getElementById("pilC").value;
            var pilD = document.getElementById("pilD").value;
            var answer = document.getElementById("answer").value;

            if (name == null || name == "") {
                err.innerHTML = "Please insert the question!";
                return false;
            }


            else if (answer == null || answer == "") {
                err.innerHTML = "Please insert the answer";
                return false;
            }
            else if (answer != pilA && answer != pilB && answer != pilC && answer != pilD) {
                err.innerHTML = "Please insert the right answer based on the option";
                return false;
            }
            else {
                return true;


            }


        }


    </script>
</head>
<body>
<form id="form1" method="post" action="savePilganGames.jsp" onsubmit="return validasi()">
    <table id="word1">
        <%

            String tipe = request.getParameter("tipe");

        %>
        <tr>
            <td>Question's Type</td>
            <td>:</td>
            <td><%=tipe%>
            </td>

        </tr>
        <tr>

            <td>Case's name</td>
            <td>:</td>
            <%
                rs = stat.executeQuery("select * from Games where gamesID = '" + id + "' ");
                while (rs.next()) {
            %>
            <td><%out.print(rs.getString("gamesName"));%></td>
            <input type="hidden" name="gamesID" id="gamesID" value="<%out.print(id);%>">

            <%}%>
        </tr>

        <tr>
            <td>Question</td>
            <td>:</td>
            <td><textarea name="question" id="question"></textarea></td>
        </tr>
        <tr>
            <td align="center">A.</td>
            <td></td>
            <td><input type="text" id="pilA" name="pilA"></td>
        </tr>

        <tr>
            <td align="center">B.</td>
            <td></td>
            <td><input type="text" id="pilB" name="pilB"></td>
        </tr>

        <tr>
            <td align="center">C.</td>
            <td></td>
            <td><input type="text" id="pilC" name="pilC"></td>
        </tr>

        <tr>
            <td align="center">D.</td>
            <td></td>
            <td><input type="text" id="pilD" name="pilD"></td>
        </tr>
        <tr>
            <td>Answer</td>
            <td>:</td>
            <td><input type="text" name="answer" id="answer"></td>
        </tr>
        <tr id="warning">
            <td colspan="3">
                <div id="err"></div>
            </td>
        </tr>
        <tr align="right">
            <td colspan="3">
                <div class="btn-fld">
                    <button type="reset">Reset</button>
                    <button type="submit">Save</button>

                </div>

            </td>
        </tr>


    </table>
</form>
</body>
</html>
